const faker = require('faker');

faker.locale = 'zh_CN';

// ****************************计划**********************
// 计划列表
const purplans = [];
for (let i = 0; i < 20; i++) {
  purplans.push({
    id: i + 1,
    order: faker.random.uuid(),
    status: Math.floor(Math.random() * 6),
    supply: Math.floor(Math.random() * 3),
    arrivalTime: Date.now(),
    creator: Math.floor(Math.random() * 3),
    depart: Math.floor(Math.random() * 3),
    createTime: Date.now(),
    submitTime: Date.now(),
    approveTime: Date.now(),
    comment: '备注'
  });
}

const pushPlans = [];
for (let i = 0; i < 5; i++) {
  pushPlans.push({
    id: i + 1,
    order: faker.random.uuid(),
    status: Math.floor(Math.random() * 6),
    supply: Math.floor(Math.random() * 3),
    arrivalTime: Date.now(),
    creator: Math.floor(Math.random()),
    depart: Math.floor(Math.random() * 3),
    createTime: Date.now(),
    approveTime: Date.now(),
    comment: '备注'
  });
}

// 物料列表
const materiels = [];
for (let i = 0; i < 8; i++) {
  materiels.push({
    id: i + 1,
    incode: faker.random.uuid(),
    name: faker.random.uuid(),
    maker: Math.floor(Math.random() * 100),
    size: Math.floor(Math.random()),
    bom: Date.now(),
    buyNum: Math.floor(Math.random()),
    buyUnit: Math.floor(Math.random() * 100),
    price: '88',
    taxRate: '66',
    countAll: '100%',
    currency: '人民币',
    arrivalTime: Date.now(),
    inCount: 80
  });
}

const finances = [];
for (let i = 0; i < 3; i++) {
  finances.push({
    id: i + 1,
    dueDate: faker.random.uuid(),
    dueScale: faker.random.uuid(),
    dueMoney: Math.floor(Math.random() * 100),
    payTerm: Math.floor(Math.random()),
    prepay: Date.now(),
    checkTerm: Math.floor(Math.random()),
    comment: Math.floor(Math.random() * 100)
  });
}
const terms = [];
for (let i = 0; i < 5; i++) {
  terms.push({
    id: i + 1,
    incode: faker.random.uuid(),
    termName: faker.random.uuid(),
    termType: Math.floor(Math.random() * 100),
    termContent: Math.floor(Math.random()),
    comment: Date.now(),
  });
}
const bills = [];
for (let i = 0; i < 2; i++) {
  bills.push({
    id: i + 1,
    billCount: faker.random.uuid(),
    currency: faker.random.uuid(),
    billType: Math.floor(Math.random() * 100),
    billDate: Math.floor(Math.random()),
    patch: Math.floor(Math.random()),
    comment: Date.now(),
  });
}

const planDetail = {
  order: '0',
  creator: '1',
  depart: '3',
  createTime: '2',
  supply: Math.floor(Math.random() * 3),
  costCenter: '6',
  comment: '10',
  materiels
};

// *****************************************************
// 订单列表
const purorders = [];
for (let i = 0; i < 20; i++) {
  purorders.push({
    id: i + 1,
    order: faker.random.uuid(),
    status: Math.floor(Math.random() * 6),
    supply: Math.floor(Math.random() * 3),
    countAll: '88',
    currency: '人民币',
    creator: Math.floor(Math.random()),
    createTime: Date.now(),
    approveTime: Date.now(),
    orderTime: Date.now(),
    stateTime: Date.now(),
    comment: ''
  });
}

const orderDetail = {
  order: '00',
  creator: '001',
  applicant: '王大伟',
  needor: '002',
  depart: '003',
  supply: Math.floor(Math.random() * 3),
  contact: '003',
  mobile: '005',
  costCenter: '006',
  buyTime: '007',
  reqOrder: '008',
  downOrder: '008',
  comment: '009',
  materiels,
  finances,
  terms,
  bills
};

export default {
  // ****************************
  getPurchasePlan: () => ({
    status: 0,
    obj: {
      pageSize: 20,
      pageNum: 1,
      totalNum: 102,
      records: purplans
    }
  }),
  getPushPlans: () => ({
    status: 0,
    obj: {
      records: pushPlans
    }
  }),
  getPlanDetail: () => ({
    status: 0,
    obj: planDetail
  }),
  deletePlan: () => ({ status: 0 }),
  savePlan: () => ({
    status: 0,
    obj: {
      id: 88,
      order: faker.random.uuid(),
      status: Math.floor(Math.random() * 6),
      supply: Math.floor(Math.random() * 3),
      arrivalTime: Date.now(),
      creator: Math.floor(Math.random() * 3),
      depart: '扭力部',
      createTime: Date.now(),
      submitTime: Date.now(),
      approveTime: Date.now(),
      comment: ''
    }
  }),
  submitPlan: () => ({ status: 0 }),
  backPlan: () => ({ status: 0 }),
  pushPlan: () => ({ status: 0 }),
  // *********************************
  getPurchaseOrder: () => ({
    status: 0,
    obj: {
      pageSize: 20,
      pageNum: 1,
      totalNum: 23,
      records: purorders
    }
  }),
  getOrderDetail: () => ({
    status: 0,
    obj: orderDetail
  }),
  deleteOrder: () => ({ status: 0 }),
  saveOrder: () => ({
    status: 0,
    obj: {
      id: 99,
      order: faker.random.uuid(),
      status: Math.floor(Math.random() * 6),
      supply: Math.floor(Math.random() * 3),
      countAll: '88',
      currency: '美元',
      creator: Math.floor(Math.random()),
      createTime: Date.now(),
      approveTime: Date.now(),
      orderTime: Date.now(),
      stateTime: Date.now(),
      comment: ''
    }
  }),
  submitOrder: () => ({ status: 0 }),
  placeOrder: () => ({ status: 0 }),
  stateOrder: () => ({ status: 0 }),
  backOrder: () => ({ status: 0 })
};
